package sort1;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowCountSortMapper extends Mapper<LongWritable, Text,FlowBean,Text>{

    FlowBean k=new FlowBean();
    Text v=new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
//facebook.com	Social Networks	880000000	47.2	9.1E+11	Yes	Yes	com

        //1.获取一行
        String line=value.toString();

        //2.切割
        String[] fields=line.split("\t");

        //3.封装对象
        String Site=fields[1];
        long UniqueVisitors=Long.parseLong(fields[3]);

        k.setUniqueVisitors(UniqueVisitors);

        v.set(Site);

        //4.写出
        context.write(k,v);

    }
}
